﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;
using CharacterInc.IncrementCharacter;
using YArchitech.Controls;
using YArchitech.Revit;
using YRevitJig;
using HYView;

namespace CharacterInc
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CharacterInc : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			this.app = commandData.Application;
			this.uidoc = this.app.ActiveUIDocument;
			this.m_document = this.uidoc.Document;
			CmdViewType types = (CmdViewType)127;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			ViewAssist.ViewValidating(this.m_document, this.m_document.ActiveView);
			if (Result.Failed == this.SelectWords())
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			this.form = new SelectWordForm();
			if (this.form.GeneralForm(this.wordstr.Charact, this.wordstr.IsChange))
			{
				if (DialogResult.Cancel != this.form.ShowDialog())
				{
					return Autodesk.Revit.UI.Result.Succeeded;
				}
				if (this.form.IncValue == -1)
				{
					return Autodesk.Revit.UI.Result.Failed;
				}
				if (!this.GetValueStr())
				{
					return Autodesk.Revit.UI.Result.Failed;
				}
				Result result;
				for (;;)
				{
					string text = "";
					this.CharactInc(ref text);
					if (!text.IsEmpty<char>())
					{
						using (XTextsJig xtextsJig = new XTextsJig(this.uidoc))
						{
							if (!this.CopyWords(text, xtextsJig))
							{
								xtextsJig.Dispose();
								result = Autodesk.Revit.UI.Result.Succeeded;
								break;
							}
							continue;
						}
						return Autodesk.Revit.UI.Result.Failed;
					}
				}
				return result;
			}
			return Autodesk.Revit.UI.Result.Failed;
		}

		public Result SelectWords()
		{
			Transaction transaction = new Transaction(this.m_document, "请选择文字信息");
			transaction.Start();
			try
			{
				List<ElementId> list = this.uidoc.Selection.GetElementIds() as List<ElementId>;
				List<ElementId> list2 = new List<ElementId>();
				foreach (ElementId elementId in list)
				{
					this.TextElem = this.uidoc.Document.GetElement(elementId);
					if (this.TextElem is TextNote)
					{
						list2.Add(elementId);
						this.words = (this.TextElem as TextNote).Text;
						break;
					}
					if (this.TextElem is ModelText)
					{
						list2.Add(elementId);
						this.words = (this.TextElem as ModelText).Text;
						break;
					}
					if (this.TextElem is RoomTag)
					{
						list2.Add(elementId);
						this.words = (this.TextElem as RoomTag).Room.Name;
						this.words = this.words.Substring(0, this.words.IndexOf(" "));
						break;
					}
					if (this.TextElem is SpaceTag)
					{
						list2.Add(elementId);
						this.words = (this.TextElem as SpaceTag).Space.Name;
						this.words = this.words.Substring(0, this.words.IndexOf(" "));
						break;
					}
				}
				if (list2.Count == 0)
				{
					SelectionFilterTextNote selectionFilterTextNote = new SelectionFilterTextNote();
					Reference reference = this.uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, selectionFilterTextNote, "请选择视图中的注释文本");
					if (reference == null)
					{
						YJKMessageBox.Show("没有选择到文本");
						transaction.RollBack();
						return Autodesk.Revit.UI.Result.Failed;
					}
					this.TextElem = this.m_document.GetElement(reference);
					if (this.TextElem is TextNote)
					{
						this.words = (this.TextElem as TextNote).Text;
					}
					else if (this.TextElem is ModelText)
					{
						this.words = (this.TextElem as ModelText).Text;
					}
					else if (this.TextElem is RoomTag)
					{
						this.words = (this.TextElem as RoomTag).Room.Name;
						this.words = this.words.Substring(0, this.words.IndexOf(" "));
					}
					else if (this.TextElem is SpaceTag)
					{
						this.words = (this.TextElem as SpaceTag).Space.Name;
						this.words = this.words.Substring(0, this.words.IndexOf(" "));
					}
				}
				this.CharactNum = this.words.Length;
				this.Chars = new char[this.CharactNum];
				this.Chars = this.words.ToCharArray();
				this.SplitStr();
				transaction.Commit();
			}
			catch (Exception)
			{
				transaction.RollBack();
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public void SplitStr()
		{
			for (int i = 0; i < this.Chars.Length; i++)
			{
				if (this.wordstr.ChsNumNoUnit.Contains(this.Chars[i]) || this.wordstr.ChsNumNoUnit.Contains(this.Chars[i]) || this.wordstr.RomeNum.Contains(this.Chars[i]) || (0 <= this.ToInt(this.Chars[i]) && this.ToInt(this.Chars[i]) <= 9) || (65 <= this.ToInt(this.Chars[i]) && this.ToInt(this.Chars[i]) <= 90) || (97 <= this.ToInt(this.Chars[i]) && this.ToInt(this.Chars[i]) <= 122))
				{
					this.wordstr.ch = true;
				}
				else
				{
					this.wordstr.ch = false;
				}
				this.wordstr.Charact.Add(this.Chars[i]);
				this.wordstr.IsChange.Add(this.wordstr.ch);
			}
			this.wordstr.RemoveSame();
		}

		public int ToInt(char str)
		{
			int result = -1;
			if (new char[]
			{
				'0',
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9'
			}.Contains(str))
			{
				result = int.Parse(str.ToString());
			}
			else if (('A' <= str && str <= 'Z') || ('a' <= str && str <= 'z'))
			{
				result = Convert.ToInt32(str);
			}
			return result;
		}

		public bool GetValueStr()
		{
			if (this.TextElem is TextNote)
			{
				this.TextNoteCoord = RevitElementExtension.GetTextNoteCoord(this.TextElem as TextNote);
			}
			else if (this.TextElem is ModelText)
			{
				this.TextNoteCoord = ((this.TextElem as ModelText).Location as LocationPoint).Point;
			}
			if (0 <= this.ToInt(this.wordstr.Charact[this.form.IncValue]) && this.ToInt(this.wordstr.Charact[this.form.IncValue]) <= 9)
			{
				return this.GetIncNum();
			}
			if (this.wordstr.AllChsNum.Contains(this.wordstr.Charact[this.form.IncValue]))
			{
				this.GetIncChs();
			}
			else if (this.wordstr.RomeNum.Contains(this.Chars[this.form.IncValue]))
			{
				for (int i = 0; i < 12; i++)
				{
					if (this.wordstr.RomeNum[i] == this.Chars[this.form.IncValue])
					{
						this.RomeIndex = i;
					}
				}
			}
			else
			{
				this.AscVal = Convert.ToInt32(this.wordstr.Charact[this.form.IncValue]);
			}
			return true;
		}

		public bool GetIncNum()
		{
			int num = 0;
			do
			{
				if (char.IsNumber(this.wordstr.Charact[this.form.IncValue - num]))
				{
					this.FrontLoopNum++;
					this.ValStr += this.wordstr.Charact[this.form.IncValue - num].ToString();
					num++;
					if (this.form.IncValue - num >= 0 && this.wordstr.Charact[this.form.IncValue - num] == '.')
					{
						this.IsDecimal = true;
						this.DecimalPt = this.form.IncValue - num;
						num++;
					}
				}
			}
			while (this.form.IncValue - num >= 0 && char.IsNumber(this.wordstr.Charact[this.form.IncValue - num]));
			char[] array = this.ValStr.ToCharArray();
			Array.Reverse(array);
			string text = null;
			for (int i = 0; i < array.Length; i++)
			{
				text += array[i].ToString();
			}
			int num2 = 1;
			do
			{
				if (this.form.IncValue + num2 <= this.wordstr.Charact.Count - 1 && char.IsNumber(this.wordstr.Charact[this.form.IncValue + num2]))
				{
					this.AfterLoopNum++;
					text += this.wordstr.Charact[this.form.IncValue + num2].ToString();
					num2++;
				}
			}
			while (this.form.IncValue + num2 <= this.wordstr.Charact.Count - 1 && char.IsNumber(this.wordstr.Charact[this.form.IncValue + num2]));
			try
			{
				this.Val = int.Parse(text);
			}
			catch (Exception)
			{
				YJKMessageBox.Show("数字过大，无法递增!请选择-2147483648 -- 2147483647之间的数字");
				return false;
			}
			if (text.Length > this.Val.ToString().Length)
			{
				this.wordstr.blZero = true;
			}
			return true;
		}

		public void GetIncChs()
		{
			int num = 0;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			char[] source = new char[this.wordstr.AllChsNum.Count<char>()];
			foreach (char value in this.wordstr.Charact)
			{
				if (this.wordstr.LowerChsNum.Contains(value) && this.wordstr.Charact[this.form.IncValue] != '零')
				{
					flag = true;
				}
				if (this.wordstr.UpperChsNum.Contains(value) && this.wordstr.Charact[this.form.IncValue] != '零')
				{
					flag2 = true;
				}
				if (flag && flag2)
				{
					flag3 = true;
				}
			}
			if (flag3)
			{
				if (this.wordstr.LowerChsNum.Contains(this.wordstr.Charact[this.form.IncValue]))
				{
					source = this.wordstr.LowerChsNum;
				}
				else
				{
					source = this.wordstr.UpperChsNum;
				}
			}
			else
			{
				source = this.wordstr.AllChsNum;
			}
			do
			{
				if (source.Contains(this.wordstr.Charact[this.form.IncValue - num]))
				{
					this.FrontLoopNum++;
					this.ValStr += this.wordstr.Charact[this.form.IncValue - num].ToString();
					num++;
					if (this.form.IncValue - num >= 0 && this.wordstr.Charact[this.form.IncValue - num] == '.')
					{
						num++;
						this.DecimalPt = this.form.IncValue - num;
					}
				}
			}
			while (this.form.IncValue - num >= 0 && source.Contains(this.wordstr.Charact[this.form.IncValue - num]));
			char[] array = this.ValStr.ToCharArray();
			Array.Reverse(array);
			string text = null;
			for (int i = 0; i < array.Length; i++)
			{
				text += array[i].ToString();
			}
			int num2 = 1;
			do
			{
				if (this.form.IncValue + num2 <= this.wordstr.Charact.Count - 1 && source.Contains(this.wordstr.Charact[this.form.IncValue + num2]))
				{
					this.AfterLoopNum++;
					text += this.wordstr.Charact[this.form.IncValue + num2].ToString();
					num2++;
				}
			}
			while (this.form.IncValue + num2 <= this.wordstr.Charact.Count - 1 && source.Contains(this.wordstr.Charact[this.form.IncValue + num2]));
			char[] array2 = text.ToCharArray();
			for (int j = 0; j < array2.Length; j++)
			{
				if (this.wordstr.LowerChsNum.Contains(array2[j]))
				{
					this.Val = NumToChsOrRome.LowerChsToNum(text);
					return;
				}
				if (this.wordstr.UpperChsNum.Contains(array2[j]))
				{
					this.Val = NumToChsOrRome.UpperChsToNum(text);
					return;
				}
			}
		}

		public string LowerChsIns()
		{
			int num = this.words.Length - this.CharactNum;
			if (this.form.IncValue == this.wordstr.Charact.Count - 1)
			{
				this.Val++;
			}
			else if (this.wordstr.Charact[this.form.IncValue] == '零')
			{
				if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 1)
				{
					this.Val += 10;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 2)
				{
					this.Val += 100;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 3)
				{
					this.Val += 1000;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 4)
				{
					this.Val += 10000;
				}
			}
			else
			{
				this.Val += NumToChsOrRome.LowerChsToUnit(this.wordstr.Charact[this.form.IncValue + 1]);
			}
			string value = NumToChsOrRome.NumberToLowerChinese(this.Val);
			this.words = this.words.Remove(this.form.IncValue - this.FrontLoopNum + 1, this.FrontLoopNum + this.AfterLoopNum + num).Insert(this.form.IncValue - this.FrontLoopNum + 1, value);
			return this.words;
		}

		public string UpperChsIns()
		{
			int num = this.words.Length - this.CharactNum;
			if (this.form.IncValue == this.wordstr.Charact.Count - 1)
			{
				this.Val++;
			}
			else if (this.wordstr.Charact[this.form.IncValue] == '零')
			{
				if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 1)
				{
					this.Val += 10;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 2)
				{
					this.Val += 100;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 3)
				{
					this.Val += 1000;
				}
				else if (this.wordstr.Charact.Count - 1 - this.form.IncValue == 4)
				{
					this.Val += 10000;
				}
			}
			else
			{
				this.Val += NumToChsOrRome.UpperChsToUnit(this.wordstr.Charact[this.form.IncValue + 1]);
			}
			string value = NumToChsOrRome.NumberToUpperChinese(this.Val);
			this.words = this.words.Remove(this.form.IncValue - this.FrontLoopNum + 1, this.FrontLoopNum + this.AfterLoopNum + num).Insert(this.form.IncValue - this.FrontLoopNum + 1, value);
			return this.words;
		}

		public string PreOrSelfNeedInc()
		{
			int num = this.words.Length - this.CharactNum;
			string text = "1";
			for (int i = 0; i < this.AfterLoopNum; i++)
			{
				text += "0";
			}
			this.Val += int.Parse(text);
			string text2 = this.Val.ToString();
			if (this.wordstr.blZero)
			{
				text2 = text2.PadLeft(this.FrontLoopNum + this.AfterLoopNum, '0');
			}
			if (this.IsDecimal)
			{
				this.words = this.words.Remove(this.form.IncValue + this.wordstr.RemoveNum - this.FrontLoopNum, this.FrontLoopNum + this.AfterLoopNum + num + 1).Insert(this.form.IncValue + this.wordstr.RemoveNum - this.FrontLoopNum, text2);
				this.words = this.words.Insert(this.DecimalPt + this.wordstr.RemoveNum, ".");
			}
			else if (this.form.IncValue < this.wordstr.SeparatorIndex)
			{
				this.words = this.words.Remove(this.form.IncValue - this.FrontLoopNum + 1, this.FrontLoopNum + this.AfterLoopNum + num).Insert(this.form.IncValue - this.FrontLoopNum + 1, text2);
			}
			else
			{
				this.words = this.words.Remove(this.form.IncValue + this.wordstr.RemoveNum - this.FrontLoopNum + 1, this.FrontLoopNum + this.AfterLoopNum + num).Insert(this.form.IncValue + this.wordstr.RemoveNum - this.FrontLoopNum + 1, text2);
			}
			return this.words;
		}

		public string UpperCaseInc()
		{
			this.AscVal++;
			if (this.AscVal > 90)
			{
				this.AscVal = 65;
			}
			this.words = this.words.Remove(this.form.IncValue, 1).Insert(this.form.IncValue, Convert.ToChar(this.AscVal).ToString());
			return this.words;
		}

		public string LowerCaseInc()
		{
			this.AscVal++;
			if (this.AscVal > 122)
			{
				this.AscVal = 97;
			}
			this.words = this.words.Remove(this.form.IncValue, 1).Insert(this.form.IncValue, Convert.ToChar(this.AscVal).ToString());
			return this.words;
		}

		public string RomeNumInc()
		{
			this.RomeIndex++;
			if (this.RomeIndex > 11)
			{
				this.RomeIndex = 0;
			}
			this.words = this.words.Remove(this.form.IncValue, 1).Insert(this.form.IncValue, this.wordstr.RomeNum[this.RomeIndex].ToString());
			return this.words;
		}

		public void CharactInc(ref string FinalText)
		{
			this.wordstr.Charact[this.form.IncValue].ToString();
			if (0 <= this.ToInt(this.wordstr.Charact[this.form.IncValue]) && this.ToInt(this.wordstr.Charact[this.form.IncValue]) <= 9)
			{
				FinalText = this.PreOrSelfNeedInc();
				return;
			}
			if (65 <= Convert.ToInt32(this.wordstr.Charact[this.form.IncValue]) && Convert.ToInt32(this.wordstr.Charact[this.form.IncValue]) <= 90)
			{
				FinalText = this.UpperCaseInc();
				return;
			}
			if (97 <= Convert.ToInt32(this.wordstr.Charact[this.form.IncValue]) && Convert.ToInt32(this.wordstr.Charact[this.form.IncValue]) <= 122)
			{
				FinalText = this.LowerCaseInc();
				return;
			}
			if (this.wordstr.LowerChsNum.Contains(this.wordstr.Charact[this.form.IncValue]))
			{
				FinalText = this.LowerChsIns();
				return;
			}
			if (this.wordstr.UpperChsNum.Contains(this.wordstr.Charact[this.form.IncValue]))
			{
				FinalText = this.UpperChsIns();
				return;
			}
			if (this.wordstr.RomeNum.Contains(this.wordstr.Charact[this.form.IncValue]))
			{
				FinalText = this.RomeNumInc();
			}
		}

		public bool CopyWords(string text, XTextsJig textjig)
		{
			new List<ElementId>();
			if (this.TextElem == null)
			{
				TaskDialog.Show("Revit", "没有选择到递增文本!");
				return false;
			}
			if (this.TextElem is TextNote)
			{
				return this.CopyTextNote(textjig);
			}
			if (this.TextElem is ModelText)
			{
				return this.CopyModelText();
			}
			if (this.TextElem is RoomTag)
			{
				return this.CopyRoomTag();
			}
			return !(this.TextElem is SpaceTag) || this.CopySpaceTag();
		}

		public bool CopyTextNote(XTextsJig textjig)
		{
			Transaction transaction = new Transaction(this.m_document, "SelectWords");
			transaction.Start("copywords");
			try
			{
				XYZ xyz = new XYZ(0.0, 0.0, 0.0);
				List<ElementId> list = ElementTransformUtils.CopyElement(this.m_document, this.TextElem.Id, xyz) as List<ElementId>;
				List<TextNote> list2 = new List<TextNote>();
				List<XYZ> list3 = new List<XYZ>();
				TextNote textNote = this.m_document.GetElement(list.Single<ElementId>()) as TextNote;
				textNote.Text = this.words;
				if (textNote != null)
				{
					BoundingBoxXYZ boundingBoxXYZ = textNote.get_BoundingBox(this.uidoc.ActiveView);
					XYZ min = boundingBoxXYZ.Min;
					XYZ max = boundingBoxXYZ.Max;
					XYZ item = min + (max - min) / 2.0;
					list2.Add(textNote);
					list3.Add(item);
				}
				this.m_document.ActiveView.HideElements(list);
				this.m_document.Regenerate();
				textNote.IsHidden(this.m_document.ActiveView);
				XYZ xyz2 = textjig.DragTexts(list2, list3, this.TextNoteCoord, "请确定位置：");
				if (xyz2 == null)
				{
					transaction.RollBack();
					return false;
				}
				Transform.CreateTranslation(xyz2 - this.TextNoteCoord);
				ElementTransformUtils.MoveElement(this.m_document, textNote.Id, xyz2 - this.TextNoteCoord);
				this.TextNoteCoord = xyz2;
				this.TextElem = textNote;
				this.m_document.ActiveView.UnhideElements(list);
				list2.Clear();
				list3.Clear();
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				transaction.Commit();
				return false;
			}
			catch (Exception)
			{
				transaction.RollBack();
				return false;
			}
			transaction.Commit();
			return true;
		}

		public bool CopyModelText()
		{
			Transaction transaction = new Transaction(this.m_document, "SelectWords");
			transaction.Start("copywords");
			try
			{
				XYZ xyz = this.uidoc.Selection.PickPoint();
				if (xyz == null)
				{
					transaction.RollBack();
					return false;
				}
				List<ElementId> list = ElementTransformUtils.CopyElement(this.m_document, this.TextElem.Id, xyz - this.TextNoteCoord) as List<ElementId>;
				ModelText modelText = this.m_document.GetElement(list.Single<ElementId>()) as ModelText;
				modelText.Text = this.words;
				this.TextNoteCoord = (modelText.Location as LocationPoint).Point;
				this.TextElem = modelText;
				list.Clear();
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				transaction.Commit();
				return false;
			}
			catch (Exception)
			{
				transaction.RollBack();
				return false;
			}
			transaction.Commit();
			return true;
		}

		public bool CopyRoomTag()
		{
			Transaction transaction = new Transaction(this.m_document, "SelectWords");
			transaction.Start("copywords");
			try
			{
				Room room = null;
				XYZ xyz = this.uidoc.Selection.PickPoint("选取房间标记位置");
				if (xyz == null)
				{
					transaction.RollBack();
					return false;
				}
				foreach (Element element in new FilteredElementCollector(this.m_document).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements())
				{
					if ((element as Room).IsPointInRoom(xyz))
					{
						room = (element as Room);
						ViewPlan viewPlan = this.m_document.ActiveView as Autodesk.Revit.DB.ViewPlan;
						Plane plane = RevitVersionFuncs.CreatePlanByOriginAndBasis(viewPlan.Origin, viewPlan.RightDirection, viewPlan.UpDirection);
						UV uv = this.wordstr.ProjectInto(plane, xyz);
						LinkElementId linkElementId = new LinkElementId((element as Room).Id);
						RoomTag roomTag = this.m_document.Create.NewRoomTag(linkElementId, uv, this.m_document.ActiveView.Id);
						roomTag.Room.Name = this.words;
						this.TextElem = roomTag;
					}
				}
				if (room == null)
				{
					TaskDialog.Show("Revit", "未将标记置于房间内!");
					transaction.RollBack();
					return false;
				}
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				transaction.Commit();
				return false;
			}
			catch (Exception)
			{
				transaction.RollBack();
				return false;
			}
			transaction.Commit();
			return true;
		}

		public bool CopySpaceTag()
		{
			Transaction transaction = new Transaction(this.m_document, "SelectWords");
			transaction.Start("copywords");
			try
			{
				Space space = null;
				XYZ xyz = this.uidoc.Selection.PickPoint("选取房间标记位置");
				if (xyz == null)
				{
					transaction.RollBack();
					return false;
				}
				foreach (Element element in new FilteredElementCollector(this.m_document).OfCategory(BuiltInCategory.OST_MEPSpaceTags).WhereElementIsNotElementType().ToElements())
				{
					if ((element as Room).IsPointInRoom(xyz))
					{
						space = (element as Space);
						ViewPlan viewPlan = this.m_document.ActiveView as Autodesk.Revit.DB.ViewPlan;
						Plane plane = RevitVersionFuncs.CreatePlanByOriginAndBasis(viewPlan.Origin, viewPlan.RightDirection, viewPlan.UpDirection);
						UV uv = this.wordstr.ProjectInto(plane, xyz);
						new LinkElementId((element as Space).Id);
						SpaceTag spaceTag = this.m_document.Create.NewSpaceTag(space, uv, this.m_document.ActiveView);
						spaceTag.Space.Name = this.words;
						this.TextElem = spaceTag;
					}
				}
				if (space == null)
				{
					TaskDialog.Show("Revit", "未将标记置于空间内!");
					transaction.RollBack();
					return false;
				}
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				transaction.Commit();
				return false;
			}
			catch (Exception)
			{
				transaction.RollBack();
				return false;
			}
			transaction.Commit();
			return true;
		}

		private SelectWordForm form;

		private UIApplication app;

		private UIDocument uidoc;

		private Document m_document;

		private XYZ TextNoteCoord;

		public char[] Chars;

		private Element TextElem;

		private string words;

		private WordStruct wordstr = new WordStruct();

		private int CharactNum;

		private int Val;

		private string ValStr;

		private int FrontLoopNum;

		private int AfterLoopNum;

		private int AscVal;

		private int RomeIndex;

		private int DecimalPt;

		private bool IsDecimal;

		private double dSingleCharWidth;
	}
}
